import axios from '@/libs/api.request'

export const login = ({ userName, password }) => {
  const data = {
    account: userName,
    password: password
  }
  return axios.request({
    url: 'admin/login',
    data,
    method: 'post',
    noToken: true,
    credentials: true
  })
}

export const loginout = () => {
  return axios.request({
    url: 'loginOut'
  })
}

export const addAdmin = ({ id, account, password, adminName, mobile, rights, status, userType}) => {
  const data = {
    id,
    account,
    password,
    adminName,
    mobile,
    rights,
    status,
    userType
  }
  return axios.request({
    url: 'admin/addAdmin',
    data,
    method: 'post'
  })
}

export const editAdmin = ({ id, account, password, adminName, mobile, rights, status, userType}) => {
  const data = {
    id,
    account,
    password,
    adminName,
    mobile,
    rights,
    status,
    userType
  }
  return axios.request({
    url: 'admin/editAdmin',
    data,
    method: 'post'
  })
}

export const getAdminList = ({pageId = 1}) => {
  const data = { pageId }
  return axios.request({
    url: 'admin/getAdminList',
    data,
    method: 'post'
  })
}

export const delAdmin = (id) => {
  return axios.request({
    url: 'admin/delAdmin',
    data: {id:id},
    method: 'post'
  })
}

export const getAdminDetail = (id) => {
  return axios.request({
    url: 'admin/getAdminDetail',
    data: { id: id },
    method: 'post'
  })
}
